home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / ImageStringData.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  3.7 KB  |  137 lines

  1. package symantec.itools.db.awt;
  2.  
  3. import java.awt.Image;
  4.  
  5. public class ImageStringData implements Data {
  6.    StringBuffer text;
  7.    // $FF: renamed from: im java.awt.Image
  8.    Image field_0;
  9.    String origText;
  10.    boolean changed;
  11.    DataSource dataSource;
  12.  
  13.    public ImageStringData(DataSource ds) {
  14.       this(ds, "", (Image)null);
  15.    }
  16.  
  17.    public ImageStringData(DataSource ds, String t) {
  18.       this(ds, t, (Image)null);
  19.    }
  20.  
  21.    public ImageStringData(DataSource ds, Image i) {
  22.       this(ds, (String)null, i);
  23.    }
  24.  
  25.    public ImageStringData(DataSource ds, String t, Image i) {
  26.       this.changed = false;
  27.       this.dataSource = ds;
  28.       this.text = new StringBuffer(t);
  29.       this.origText = t;
  30.       this.field_0 = i;
  31.    }
  32.  
  33.    public int type() {
  34.       if (this.text != null && this.field_0 != null) {
  35.          return 3;
  36.       } else {
  37.          return this.field_0 == null ? 1 : 2;
  38.       }
  39.    }
  40.  
  41.    public boolean isEditable(int row, int col) {
  42.       return this.dataSource.isDataEditable(row, col);
  43.    }
  44.  
  45.    public boolean changed() {
  46.       return this.changed;
  47.    }
  48.  
  49.    public void rollback() {
  50.       this.text.setLength(0);
  51.       this.text.append(this.origText);
  52.       this.changed = false;
  53.    }
  54.  
  55.    public void commit() throws TypeNotSupported {
  56.       if (this.changed) {
  57.          this.origText = this.text.toString();
  58.          this.changed = false;
  59.       }
  60.  
  61.    }
  62.  
  63.    public boolean isMasked() {
  64.       return false;
  65.    }
  66.  
  67.    public String getMask() throws TypeNotSupported {
  68.       throw new TypeNotSupported("ImageStringData does not support choices");
  69.    }
  70.  
  71.    public boolean supportsChoice() {
  72.       return false;
  73.    }
  74.  
  75.    public Data[] getChoices() throws TypeNotSupported {
  76.       throw new TypeNotSupported("ImageStringData does not support choices");
  77.    }
  78.  
  79.    public void setImage(Image i) {
  80.       this.changed = true;
  81.       this.field_0 = i;
  82.    }
  83.  
  84.    public void setText(String t) {
  85.       this.text.setLength(0);
  86.       this.text.append(t);
  87.       this.changed = true;
  88.    }
  89.  
  90.    public void setText(char c) {
  91.       this.text.setLength(0);
  92.       this.text.append(c);
  93.       this.changed = true;
  94.    }
  95.  
  96.    public void insertChar(int pos, char c) {
  97.       this.text.insert(pos, c);
  98.       this.changed = true;
  99.    }
  100.  
  101.    public void appendChar(char c) {
  102.       this.text.append(c);
  103.       this.changed = true;
  104.    }
  105.  
  106.    public String subString(int spos, int epos) {
  107.       return this.text.toString().substring(spos, epos);
  108.    }
  109.  
  110.    public void deleteChar(int pos) {
  111.       if (pos > 0) {
  112.          String t = this.text.toString();
  113.          this.text.setLength(0);
  114.          this.changed = true;
  115.          if (pos >= t.length()) {
  116.             this.text.append(t.substring(0, t.length() - 1));
  117.          } else {
  118.             this.text.append(t.substring(0, pos - 1));
  119.             this.text.append(t.substring(pos, t.length()));
  120.          }
  121.       }
  122.    }
  123.  
  124.    public void clearText() {
  125.       this.text.setLength(0);
  126.       this.changed = true;
  127.    }
  128.  
  129.    public String toString() {
  130.       return this.text.toString();
  131.    }
  132.  
  133.    public Image toImage() {
  134.       return this.field_0;
  135.    }
  136. }
  137.